﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Globalization;
using Public;

namespace WebsiteAdmin.Wilson.ProInfo.Handler
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class CatUpdate : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (Cookie.AdminLoginName != null && Cookie.AdminLoginName != "")
            {
                int rtn = 0;
                string catName = context.Request["CatTitle"].ToString();
                string catCode = context.Request["UrlName"].ToString();
                string imgURL = context.Request["ImgURL"].ToString();
                string description = context.Request["Description"].ToString();
                int sortBy = Convert.ToInt32(context.Request["SortBy"], CultureInfo.InvariantCulture);
                int pkid = Convert.ToInt32(context.Request["PKID"], CultureInfo.InvariantCulture);
                rtn = Update(Global.ConnWilson, catName, catCode, imgURL, description, sortBy, pkid);
                context.Response.Write(rtn == 1 ? "{\"Done\":\"Success\"}" : "{\"Done\":\"Failed\"}");
            }
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

        private int Update(string strCon,string catName,string catCode,string imgURL,string description,int sortBy,int pkid) 
        {
            return Bll.Category.Update(strCon, catName, catCode, imgURL, description, sortBy, pkid);
        }
    }
}
